<html>
<head>
<title>Insert Smiley</title>
<link rel="stylesheet" type="text/css" href="../../../popups/popup.css" />
<script type="text/javascript" src="../../../popups/popup.js"></script>
<script type="text/javascript">

var InsertSmiley = window.opener.InsertSmiley;
var editor = null;
var param;

function Init() {
  var totalsmileys = 580;
  __dlg_translate("InsertSmiley");
  __dlg_init();
  param = window.dialogArguments;
  editor = param['editor'];
  window.resizeTo(400, 300);
  var tbody = document.getElementById("smileytable");
  var inum;
  var trow;
  for(var i = 1; i <= totalsmileys; i++) {
    if((i - 1) % 4 == 0) {
	  trow = tbody.insertRow((i - 1) / 4);
	}
	// find new number to be found in smileys folder
	inum = "";
	if(i < 1000) {
	  if(i < 100) {
		if(i < 10) {
		  inum = "000" + i;
		} else {
		  inum = "00" + i;
		}
	  } else {
	    inum = "0" + i;
	  }
	} else {
	  inum = i;
	}
	trow.insertCell((i - 1) % 4).innerHTML = "<a href=\"javascript:onOK('" + inum + "')\"><img style=\"border: 0px;\" alt=\"Smiley " + + i + "\" src=\""+ param.editor_url +"plugins/InsertSmiley/smileys/" + inum + ".gif\" />";
  }
  document.body.onkeypress = __dlg_key_press;
}

function onCancel() {
  //__dlg_close(null);
  window.close();
  return false;
}

function onOK(smileynum) {
  var params = {};
  params.imgURL = param.editor_url +"plugins/InsertSmiley/smileys/" + smileynum + ".gif";
  __dlg_close(params);
  return false;
}

function __dlg_key_press(ev) {
  ev || (ev = window.event);
  switch(ev.keyCode) {
    case 13:
    document.getElementById('bt_ok').click();
      break;
    case 27:
    __dlg_close();
    return false;
  }
return true;
}
</script>

<style type="text/css">
.buttons {border-top: 1px solid #999; padding: 5px; text-align: right; height: 20px; }
</style>
</head>
  <body class="dialog" onLoad="Init()">
<form action="" method="get">
  <div class="title" style="width: 360px;">Insert Smiley</div>
  <div style="height: 175px; overflow:auto;" align="center">
  <table style="border: 0; width: 370px;" id="smileytable" name="smileytable">
  </table>
  </div>
<div class="space"></div>
<div class="buttons">
<button type="button" onClick="return onCancel();">Cancel</button>
</div>
<div id="showselect" style="position:absolute; left:7px; top:75px; width:150px; z-index:100; visibility: visible; height: 13px; color: red;">
</div>
</form>
</body>
</html>